home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 003-desktop.lzm / usr / bin / preparetips < prev    next >
Encoding:
Text File  |  2005-09-10  |  971 b   |  67 lines

  1. #! /usr/bin/perl
  2. # little script to extract the text from the tips file
  3. # and output it, so xgettext can add the tips to the po file
  4. #
  5. # 2000 by Matthias Kiefer <matthias.kiefer@gmx.de>
  6.  
  7. # IMPORTANT NOTE: Do not change the output without checking if
  8. # translations still work!
  9.  
  10. sub printText
  11. {
  12.     my $text = $_[0];
  13.     
  14.     if ( $text cmp "" )
  15.     {
  16.  
  17.     # replace \ with \\
  18.     $text =~ s/\\/\\\\/g;
  19.  
  20.     # replace " with \"
  21.     $text =~ s/"/\\"/g;
  22.             
  23.     print "\"$text\\n\"\n";
  24.     }
  25. }
  26.  
  27. open(FILE,"<","tips") or die "unable to open tips file";
  28. if ( $^V ge v5.8.0 )
  29. {
  30.     binmode(FILE,":utf8");
  31.     binmode(STDOUT,":utf8");
  32. }
  33.  
  34. $inTip=0;
  35.  
  36. while(<FILE>)
  37. {
  38.     chomp;
  39.  
  40.     # tip starts with <html>
  41.     if(/^\s*<html>(.*)/io)
  42.     {
  43.         $inTip=1;
  44.         print "//i18n file tips.cpp line $.\n";
  45.         print "i18n(\n";
  46.         printText($1);
  47.         next;
  48.     }    
  49.  
  50.     if($inTip!=0)
  51.     {
  52.         # tip ends with </html>
  53.         if(/^(.*)\s*<\/html>/io)
  54.         {
  55.             printText($1);
  56.             print ");\n\n";
  57.             $inTip=0;
  58.         }
  59.         else
  60.         {
  61.             printText($_);
  62.         }
  63.     }   
  64. }
  65.  
  66. close(FILE);
  67.